/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author ivanhoe
 */
@Entity
@Table(name = "tipos_venta")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TiposVenta.findAll", query = "SELECT t FROM TiposVenta t"),
    @NamedQuery(name = "TiposVenta.findByIdTipoVenta", query = "SELECT t FROM TiposVenta t WHERE t.idTipoVenta = :idTipoVenta"),
    @NamedQuery(name = "TiposVenta.findByNombreTipoVenta", query = "SELECT t FROM TiposVenta t WHERE t.nombreTipoVenta = :nombreTipoVenta")})
public class TiposVenta implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "id_tipo_venta")
    private Integer idTipoVenta;
    @Size(max = 45)
    @Column(name = "nombre_tipo_venta")
    private String nombreTipoVenta;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idTipoVenta")
    private Collection<Ventas> ventasCollection;

    public TiposVenta() {
    }

    public TiposVenta(Integer idTipoVenta) {
        this.idTipoVenta = idTipoVenta;
    }

    public Integer getIdTipoVenta() {
        return idTipoVenta;
    }

    public void setIdTipoVenta(Integer idTipoVenta) {
        this.idTipoVenta = idTipoVenta;
    }

    public String getNombreTipoVenta() {
        return nombreTipoVenta;
    }

    public void setNombreTipoVenta(String nombreTipoVenta) {
        this.nombreTipoVenta = nombreTipoVenta;
    }

    @XmlTransient
    public Collection<Ventas> getVentasCollection() {
        return ventasCollection;
    }

    public void setVentasCollection(Collection<Ventas> ventasCollection) {
        this.ventasCollection = ventasCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idTipoVenta != null ? idTipoVenta.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TiposVenta)) {
            return false;
        }
        TiposVenta other = (TiposVenta) object;
        if ((this.idTipoVenta == null && other.idTipoVenta != null) || (this.idTipoVenta != null && !this.idTipoVenta.equals(other.idTipoVenta))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.TiposVenta[ idTipoVenta=" + idTipoVenta + " ]";
    }
    
}
